package JUC;

import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;

//ConcurrentModificationException
public class MapTest {
    public static void main(String[] args) {
        //工作不用hashmap
        //
        //Map<String,String> map=new HashMap<>();
        //加载因子、初始容量
        //Collections.synchronizedMap()安全集合工具类
        ConcurrentHashMap<String,String> map = new ConcurrentHashMap<>();//线程安全集合

        for (int i = 0; i <30 ; i++) {
            new Thread(()->{
                map.put(Thread.currentThread().getName(), UUID.randomUUID().toString().substring(0,5));
                System.out.println(map);
            },String.valueOf(i)).start();
        }

    }
}
